#pragma once

#include <string>
#include "memdb/memdb.h"

namespace app {

class Application {
public:
		Application();
		~Application();
		void run();

protected:
		virtual void start();
		virtual void stop();
		const std::string & getDataDir() const {
			return dataDir;
		}
private:
		std::string dataDir;
		memdb::IDB * db;
};
}//namespace app
 

namespace app {

class DataGrid {
public:
	DataGrid();
	~DataGrid();
	
	void setDataSource(memdb::ITable & table);
	memdb::ITable &  dataSource() {
		return *_table;
	}

	
	// 0 - 1 = -1  ===> 0
	// 1 - 1 = +0  ===> 0
	// 2 - 1 = +1  ===> 1
	// 2 - 10 = -8 ====> 0
	int calcUp(int current, size_t step);
	//TODO: testcase
	int calcDown(int current, size_t step, size_t max);


	void up(size_t cntRecord);
	void down(size_t cntRecord);
	void pagesUp(size_t cntPages);
	void pagesDown(size_t cntPages);

	const int current() const {
		return _current;
	}
	const size_t pageSize() const {
		return _pageSize;
	}
private:
	memdb::ITable * _table;	
	int _current;
	size_t _pageSize;
};

}//namspace app

